package com.itany.conf;

import com.itany.interptor.Interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class TestMvcConfig implements WebMvcConfigurer {

    //添加ViewController
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/showMain").setViewName("index");

        registry.addViewController("/showLogin").setViewName("login");

        registry.addViewController("/showList").setViewName("userlist");

        registry.addViewController("/showBook").setViewName("booklist");
        registry.addViewController("/showSupplierExamine").setViewName("supplier_examine");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new Interceptor())
                .addPathPatterns("/**")   //拦截
                .excludePathPatterns("/showLogin")
                .excludePathPatterns("/managerUser/login");
    }
}
